#include <bits/stdc++.h>
using namespace std;
#define mm(a) memset(a,0,sizeof(a));
int calc(string line) {
    if (line.back() != ')') line += " (+0)";
    int h1, m1, s1, h2, m2, s2, d;
    sscanf(line.c_str(), "%d:%d:%d %d:%d:%d (+%d)", &h1, &m1, &s1, &h2, &m2, &s2, &d);
    int departure = h1 * 3600 + m1 * 60 + s1;
    int arrival = h2 * 3600 + m2 * 60 + s2;
    return arrival - departure + d * 24 * 3600;
}

int main() {
    int n;
    cin >> n;
    getchar();
    vector<int> res;
    while (n--) {
        string go;
        getline(cin, go);
        string back;
        getline(cin, back);
        int sec = (calc(go) + calc(back)) / 2;
        printf("%02d:%02d:%02d\n", sec / 3600, sec / 60 % 60, sec % 60);
    }
    return 0;
}